﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.OleDb;
namespace HotelManager.Data_Access_Layer
{
    public class chitietdichvuDAO:ConnectDAO
    {
        OleDbCommand cmd;
        OleDbConnection ketNoi = null;
        public void ThemCTDV()
        {
            try
            {
                cmd.CommandText = "insert into chitietdichvu (ctdv_tendichvu,ctdv_giadichvu,ctdv_uudai,ctdv_tonkho) values()";
                cmd.CommandType = CommandType.Text;
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close(); 
            }
        }
        public void HienThiCTDV()
        {
            try
            {
                cmd.CommandText = "select* from chitietdichvu ctdv";
                cmd.CommandType = CommandType.Text;
                ketNoi = null; ketNoi = KetNoi();

                OleDbDataReader rd = cmd.ExecuteReader();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close(); 
            }
        }
        public void SuaCTDV()
        {
            try
            {
                cmd.CommandText = "update chitietdichvu set ctdv_tendichvu= ctdv_giadichvu= ctdv_uudai= ctdv_tonkho= where ctdv_id=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close(); 
            }
        }
        public void SuaCTDV_tendichvu()
        {
            try
            {
                cmd.CommandText = "update chitietdichvu set ctdv_tendichvu= where ctdv_id=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close();
            }
        }
        public void SuaCTDV_giadichvu()
        {
            try
            {
                cmd.CommandText = "update chitietdichvu set ctdv_giadichvu= where ctdv_id=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close();
            }
        }
        public void SuaCTDV_uudai()
        {
            try
            {
                cmd.CommandText = "update chitietdichvu set ctdv_uudai= where ctdv_id=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close();
            }
        }
        public void SuaCTDV_tonkho()
        {
            try
            {
                cmd.CommandText = "update chitietdichvu set ctdv_tonkho= where ctdv_id=";
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close();
            }
        }
        public void XoaCTDV()
        {
            try
            {
                cmd.CommandText = "delete from chitietdichvu where ctdv_id= ";
                cmd.CommandType = CommandType.Text;
                ketNoi = null; ketNoi = KetNoi();
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (ketNoi != null)
                    ketNoi.Close(); 
            }
        }
    }
}
